import request from '@/utils/request'

const module = '/admin/system/user'
// 查询用户分页列表
export const GetUsers = (pageNum, pageSize, searchObj) => {
  return request({
    url: `${module}/list/${pageNum}/${pageSize}`,
    method: 'GET',
    //axios传所有的参数(头、体、请求参数)必须都是json对象
    params: searchObj, // {keyword:'xx' , start:'xx'}
  })
}
//删除指定用户
export const DeleteUserById = id => {
  return request({
    url: `${module}/deleteById/${id}`,
    method: 'DELETE',
  })
}
//新增用户
export const SaveUser = sysUser => {
  return request({
    url: `${module}/save`,
    method: 'POST',
    data: sysUser,
  })
}
//查询指定用户
export const GetUserById = id => {
  return request({
    url: `${module}/getById/${id}`,
    method: 'GET',
  })
}
//更新用户
export const UpdateUser = sysUser => {
  return request({
    url: `${module}/update`,
    method: 'PUT',
    data: sysUser,
  })
}
//给用户分配角色
export const AssignRoles2User = (roleIds, userId) => {
  return request({
    url: `/admin/system/userRole/assignRoles2User/${userId}`,
    method: 'PUT',
    data: roleIds, // [1,2,3]
  })
}
